import request from '@/utils/request';

export const getArticlesByIdAPI = (channel_id: number, timestamp: number) => {
  return request({ url: '/v1_0/articles', params: { channel_id, timestamp } });
};

export const getDetailByIdAPI = (id: string) => {
  return request({ url: '/v1_0/articles/' + id });
};

export const followByIdAPI = (id: string) => {
  return request({
    url: '/v1_0/user/followings',
    method: 'post',
    data: {
      target: id,
    },
  });
};

export const disfollowByIdAPI = (id: string) => {
  return request({
    url: '/v1_0/user/followings/' + id,
    method: 'delete',
  });
};

export const likeByIdAPI = (id: string) => {
  return request({
    url: '/v1_0/article/likings',
    method: 'post',
    data: {
      target: id,
    },
  });
};

export const disLikeByIdAPI = (id: string) => {
  return request({ url: '/v1_0/article/likings/' + id, method: 'delete' });
};

export const collectByIdAPI = (id: string) => {
  return request({
    url: '/v1_0/article/collections',
    method: 'post',
    data: {
      target: id,
    },
  });
};
export const disCollectByIdAPI = (id: string) => {
  return request({ url: '/v1_0/article/collections/' + id, method: 'delete' });
};

export const getCommentsByIdAPI = (id: string, type: 'a' | 'c') => {
  return request({
    url: '/v1_0/comments',
    params: {
      type,
      source: id,
    },
  });
};
